import { request } from "@yaf/request";
import { toApi } from "@/service/proxyApi";
import {RequestDataType, RespDataType} from "./apiType";
export * from "./apiType";

export { getAllowUserUseRoles } from "../../../api";

const {get, postJSON, del, put } = request;

/**
 * 获取用户分页列表数据
 */
export const getUserPageList = (params: {page:number, pageSize: number, deptId?: number, keyWords?: string, mobile?: string, status?: number}) => {
    return get<PageList<RespDataType.UserItem>>(toApi("api/v1/system/user/list"), params);
}

/**
 * 创建用户
 */
export const createUser = (params:RequestDataType.CreateUserItem) => {
    return postJSON(toApi("api/v1/system/user/add"), params);
}

/**
 * 获取用户信息
 */
export const getUserInfo = (userId: number) => {
    return get<RespDataType.UserEditData>(toApi("api/v1/system/user/getEdit"), {id: userId});
}

/**
 * 更新用户信息
 */
export const updateUserInfo = (params:RequestDataType.UpdateUserItem) => {
    return put(toApi("api/v1/system/user/edit"), params);
}

/**
 * 删除用户信息
 */
export const deleteUserInfo = (userIds:number[]) => {
    return del(toApi("api/v1/system/user/delete"), {ids: userIds});
}

